import { V as o } from "./vendor-BOsc3Pjv.js";
import {
  n as r,
  cs as m,
  ct as h,
  bG as c,
  j as d,
  aB as u,
  aL as _,
  i as p,
  ac as w,
  cu as f,
  cv as v,
  cw as y,
  cx as x,
} from "./index-Dr7F7vam.js";
const P = o.extend({});
var g = function (t, s) {
    return t(
      "div",
      { staticClass: "ax-project-info-section" },
      [
        s._t("header", function () {
          return [
            t("div", { staticClass: "info-section__header" }, [
              t("div", { staticClass: "row align-items-center" }, [
                t("div", { staticClass: "col" }, [
                  t(
                    "div",
                    { staticClass: "section-title" },
                    [s._t("title")],
                    2
                  ),
                ]),
                t("div", { staticClass: "col-auto" }, [
                  t(
                    "div",
                    { staticClass: "info-section__title-actions" },
                    [s._t("title-actions")],
                    2
                  ),
                ]),
              ]),
            ]),
          ];
        }),
        t("div", { staticClass: "section-content" }, [s._t("default")], 2),
      ],
      2
    );
  },
  C = [],
  j = r(P, g, C, !0, null, null, null, null);
const b = j.exports,
  A = { type: Object, required: !0, validator: (e) => c(e) },
  G = o.extend({
    props: { full: { type: Boolean, default: !1 }, project: A },
    computed: {
      url() {
        return this.full ? this.urls.full : this.urls.display;
      },
      urls() {
        const e = this.project;
        return this.$store.getters.prototypeUrls(e);
      },
    },
    methods: {
      openPrototypeLink(e) {
        if (this.project.isUserOnlyWorkspace) m(this.urls, e);
        else if (this.project.hasPassword) h(this.urls, e);
        else return !0;
      },
    },
  }),
  $ = o.extend({
    components: { AxButton: d, AxForm: u, AxInput: _, AxIcon: p },
    props: {
      shortcut: { type: String, required: !0 },
      hasPassword: { type: Boolean, default: !1 },
      hideOverlay: { type: Boolean, default: !1 },
    },
    data() {
      return {
        dialog: !1,
        dummyPassword: "*************",
        model: { password: "" },
        loading: !1,
      };
    },
    computed: {
      isSubInstance() {
        const { axShareConfig: e } = this.$store.state;
        return e !== null && e.IsSubInstance;
      },
      passwordStatus() {
        return this.hasPassword ? this.dummyPassword : "未设置";
      },
    },
    watch: {
      async dialog(e) {
        e &&
          (await this.loadingPassword(),
          requestAnimationFrame(() => {
            const t = this.$refs.focus;
            t && t.focus && (t.select(), t.focus());
          }));
      },
    },
    methods: {
      async loadingPassword() {
        const t = {
          action: async () => {
            if (((this.loading = !0), this.hasPassword))
              if (this.isSubInstance) this.model.password = this.dummyPassword;
              else {
                const s = await v(this.shortcut);
                if (s && s.Vars) {
                  const { password: a } = s.Vars;
                  a && (this.model.password = a);
                }
              }
            else this.model.password = "";
            this.loading = !1;
          },
        };
        await this.$store.dispatch(new w(t));
      },
      async change() {
        (this.dialog = !0), this.$emit("show", this.dialog);
      },
      async submit({ values: e }) {
        await this.setPassword(e.password), (this.dialog = !1);
      },
      close() {
        this.dialog = !1;
      },
      async setPassword(e) {
        await this.$store.dispatch(new f(this.shortcut, { Password: e })),
          await this.loadingPassword();
      },
    },
  });
var k = function () {
    var t = this,
      s = t._self._c;
    return (
      t._self._setupProxy,
      s(
        "div",
        [
          t._t(
            "default",
            function () {
              return [
                t.dialog
                  ? t._e()
                  : s(
                      "AxButton",
                      {
                        staticClass: "pw-status",
                        attrs: {
                          title: "更改访问代码",
                          color: "link",
                          small: "",
                        },
                        on: { click: t.change },
                      },
                      [
                        t._v(" " + t._s(t.passwordStatus) + " "),
                        t.hasPassword
                          ? t._e()
                          : s("AxIcon", {
                              staticClass: "icon-pen",
                              attrs: { name: "edit-pen-gray" },
                            }),
                      ],
                      1
                    ),
              ];
            },
            { change: t.change }
          ),
          t.dialog
            ? s(
                "div",
                [
                  s("AxForm", {
                    staticClass: "set-pwd-form",
                    attrs: { value: t.model, submit: t.submit },
                    scopedSlots: t._u(
                      [
                        {
                          key: "default",
                          fn: function ({
                            values: a,
                            handleSubmit: n,
                            submitting: i,
                          }) {
                            return [
                              s(
                                "form",
                                [
                                  s("AxInput", {
                                    ref: "focus",
                                    attrs: {
                                      autofocus: "",
                                      "prevent-password-manager": "",
                                      "disable-label": "",
                                      type: t.isSubInstance
                                        ? "password"
                                        : "text",
                                      readonly: t.loading,
                                    },
                                    model: {
                                      value: a.password,
                                      callback: function (l) {
                                        t.$set(a, "password", l);
                                      },
                                      expression: "values.password",
                                    },
                                  }),
                                  s(
                                    "AxButton",
                                    {
                                      attrs: {
                                        disabled:
                                          i ||
                                          (t.hasPassword &&
                                            (a.password === t.dummyPassword ||
                                              a.password === t.model.password)),
                                        type: "submit",
                                        color: "primary",
                                        small: "",
                                      },
                                      on: {
                                        click: function (l) {
                                          return (
                                            l.preventDefault(),
                                            n.apply(null, arguments)
                                          );
                                        },
                                      },
                                    },
                                    [t._v(" 保存 ")]
                                  ),
                                  s(
                                    "AxButton",
                                    {
                                      attrs: { color: "secondary", small: "" },
                                      on: { click: t.close },
                                    },
                                    [t._v(" 取消 ")]
                                  ),
                                ],
                                1
                              ),
                            ];
                          },
                        },
                      ],
                      null,
                      !1,
                      2503258695
                    ),
                  }),
                ],
                1
              )
            : t._e(),
        ],
        2
      )
    );
  },
  S = [],
  I = r($, k, S, !1, null, "b491df17", null, null);
const B = I.exports,
  O = { type: Object, required: !0 },
  F = o.extend({
    components: {
      AxProjectInfoSection: b,
      AxProjectSetPassword: B,
      AxForm: u,
      AxButton: d,
      AxIcon: p,
    },
    props: { hideOverlay: { type: Boolean, default: !1 }, project: O },
    data() {
      return { deleteConfirmation: !1 };
    },
    computed: {
      info() {
        return this.project.listingNode;
      },
    },
    methods: {
      toggled(e) {
        this.$emit("toggle", e);
      },
      showDeleteConfirmation() {
        this.deleteConfirmation = !0;
      },
      closeDeleteConfirmation() {
        this.deleteConfirmation = !1;
      },
      async deletePassword() {
        await this.$store.dispatch(new f(this.project.id, { Password: "" })),
          (this.deleteConfirmation = !1);
      },
    },
  });
var R = function () {
    var t = this,
      s = t._self._c;
    return (
      t._self._setupProxy,
      s(
        "div",
        { staticClass: "access-code-form" },
        [
          t.info && !t.project.isUserOnly
            ? s(
                "AxProjectInfoSection",
                {
                  scopedSlots: t._u(
                    [
                      {
                        key: "title",
                        fn: function () {
                          return [
                            s("span", { staticClass: "fw-normal title-text" }, [
                              t._v(" 访问码 "),
                            ]),
                            t.info.HasPassword
                              ? s(
                                  "AxButton",
                                  {
                                    staticClass: "button-delete",
                                    attrs: { color: "link", small: "" },
                                    on: { click: t.showDeleteConfirmation },
                                  },
                                  [s("AxIcon", { attrs: { name: "delete" } })],
                                  1
                                )
                              : t._e(),
                            t.deleteConfirmation
                              ? s(
                                  "div",
                                  { staticClass: "delete-confirm" },
                                  [
                                    s("div", { staticClass: "popup-arrow" }),
                                    s("AxForm", {
                                      attrs: { submit: t.deletePassword },
                                      scopedSlots: t._u(
                                        [
                                          {
                                            key: "default",
                                            fn: function ({
                                              handleSubmit: a,
                                              submitting: n,
                                            }) {
                                              return [
                                                s("form", [
                                                  s(
                                                    "div",
                                                    {
                                                      staticClass:
                                                        "col delete-confirm-label",
                                                    },
                                                    [t._v(" 你确定吗? ")]
                                                  ),
                                                  s(
                                                    "div",
                                                    {
                                                      staticClass:
                                                        "row delete-confirm-body",
                                                    },
                                                    [
                                                      s(
                                                        "div",
                                                        {
                                                          staticClass:
                                                            "col-auto",
                                                        },
                                                        [
                                                          s(
                                                            "AxButton",
                                                            {
                                                              staticClass:
                                                                "delete-cancel-btn",
                                                              attrs: {
                                                                block: "",
                                                                color:
                                                                  "secondary",
                                                                small: "",
                                                              },
                                                              on: {
                                                                click:
                                                                  t.closeDeleteConfirmation,
                                                              },
                                                            },
                                                            [t._v(" 取消 ")]
                                                          ),
                                                        ],
                                                        1
                                                      ),
                                                      s(
                                                        "div",
                                                        {
                                                          staticClass:
                                                            "col-auto",
                                                        },
                                                        [
                                                          s(
                                                            "AxButton",
                                                            {
                                                              staticClass:
                                                                "delete-confirm-btn",
                                                              attrs: {
                                                                type: "submit",
                                                                color: "danger",
                                                                block: "",
                                                                disabled: n,
                                                                small: "",
                                                              },
                                                              on: {
                                                                click:
                                                                  function (i) {
                                                                    return (
                                                                      i.preventDefault(),
                                                                      a.apply(
                                                                        null,
                                                                        arguments
                                                                      )
                                                                    );
                                                                  },
                                                              },
                                                            },
                                                            [t._v(" 删除 ")]
                                                          ),
                                                        ],
                                                        1
                                                      ),
                                                    ]
                                                  ),
                                                ]),
                                              ];
                                            },
                                          },
                                        ],
                                        null,
                                        !1,
                                        3574168754
                                      ),
                                    }),
                                  ],
                                  1
                                )
                              : t._e(),
                          ];
                        },
                        proxy: !0,
                      },
                    ],
                    null,
                    !1,
                    3887121995
                  ),
                },
                [
                  t.project.viewOnly
                    ? t._e()
                    : s("AxProjectSetPassword", {
                        attrs: {
                          shortcut: t.project.id,
                          "has-password": t.info.HasPassword,
                          "hide-overlay": t.hideOverlay,
                        },
                        on: { toggle: t.toggled },
                      }),
                ],
                1
              )
            : t._e(),
        ],
        1
      )
    );
  },
  D = [],
  q = r(F, R, D, !1, null, "92d2934f", null, null);
const M = q.exports,
  L = { type: Object, required: !0, validator: (e) => c(e) },
  N = o.extend({
    components: { AxEditable: y },
    props: { project: L },
    computed: {
      activateRename() {
        return !!this.$route.params.autorename;
      },
    },
    methods: {
      async submitRename(e) {
        await this.$store.dispatch(new x(this.project.id, e));
      },
    },
  });
var H = function () {
    var t = this,
      s = t._self._c;
    return (
      t._self._setupProxy,
      s(
        "div",
        { staticClass: "ax-project-name" },
        [
          t.project.viewOnly
            ? s("div", { staticClass: "ax-project-name__editable" }, [
                t._v(" " + t._s(t.project.name) + " "),
              ])
            : s("AxEditable", {
                staticClass: "ax-project-name__editable",
                attrs: {
                  title: t.project.name,
                  value: t.project.name,
                  submit: t.submitRename,
                  "activate-on-creation": t.activateRename,
                },
              }),
        ],
        1
      )
    );
  },
  U = [],
  V = r(N, H, U, !1, null, "08e7670c", null, null);
const W = V.exports;
export { b as A, M as a, W as b, G as s };
